<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增售后预约')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-customer-add">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">[[#{bookPhone}]]：</label>
                    <div class="col-sm-8">
                        <input name="countryCode" class="input-line" type="number" maxlength="5" style="width: 70px;" placeholder="国家码">
                        <span>-</span>
                        <input name="phoneNumber" class="input-line" type="number" maxlength="11" style="width: 120px;" placeholder="电话" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">[[#{email}]]：</label>
                    <div class="col-sm-8">
                        <input name="email" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">[[#{address}]]：</label>
                    <div class="col-sm-8">
                        <input name="fullAddress" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">[[#{bookRepairTime}]]：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="repairTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">[[#{deviceModel}]]：</label>
                    <div class="col-sm-8">
                        <input name="deviceModelNo" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">[[#{faultProblem}]]：</label>
                    <div class="col-sm-8">
                        <textarea name="problem" class="form-control" rows="5" required></textarea>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">[[#{faultProblem}]]：</label>
                    <div class="col-sm-8">
                        <select name="repairUserId" id="repairUserId" class="form-control">
                            <option value="">-请选择-</option>
                            <option th:each="item: ${repairList}" th:value="${item.userId}" th:text="${item.userName}" th:phoneNumber="${item.phonenumber}" ></option>
                        </select>

                        <input name="repairBy" class="form-control" type="hidden">
                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请将维修人员，权限设置为：repairer。</span>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">[[#{contactNumber}]]：</label>
                    <div class="col-sm-8">
                        <input name="repairPhoneNumber" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "business/customer"
        $("#form-customer-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-customer-add').serialize());
            }
        }

        $("input[name='repairTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("#repairUserId").bind("change", function() {
            var repair = $(this).find("option:selected").text();
            var phoneNumber = $(this).find("option:selected").attr("phoneNumber");
            console.log(repair);
            console.log("==="+phoneNumber);
            $("input[name='repairBy']").val(repair);
            $("input[name='repairPhoneNumber']").val(phoneNumber);
        });
    </script>
</body>
</html>